﻿using Microsoft.EntityFrameworkCore.ChangeTracking;
using System.ComponentModel.DataAnnotations;

namespace nhCore.db;

public class Station
{
    [Display(Name = "设备名称"), StringLength(20)]
    public string Name { get; set; } = null!;

    [Key]
    public byte Id { get; set; }

    [Display(Name = "握手帧"), StringLength(4)]
    public string HandshakeFrame { get; set; } = null!;

    [Display(Name = "设备类型"), StringLength(20)]
    public string? Type { get; set; }

    virtual public ObservableCollectionListSource<ElementConfig> ElementConfigs { get; set; } = [];

    public Station(string handshakeFrame, string name)
    {
        HandshakeFrame = handshakeFrame;
        Name = name;
    }

    public Station()
    {

    }

    public string Display()
    {
        return string.Format($"{Name}[{Id:d2}]");
    }
}
